package com.xzit.rcpyxt.dto;

import com.xzit.rcpyxt.constant.MessageCode;

/**
 * 自定义返回值模型
 */
public class ResultModel {

    /**
     * 返回码
     */
    private int code;

    /**
     * 返回结果描述
     */
    private String message;

    /**
     * 返回内容
     */
    private Object data;

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public Object getData() {
        return data;
    }

    public ResultModel(int code, String message) {
        this.code = code;
        this.message = message;
        this.data = "";
    }

    public ResultModel(int code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public ResultModel(ResultModel resultModel) {
        this.code = resultModel.getCode();
        this.message = resultModel.getMessage();
        this.data = "";
    }

    public ResultModel(MessageCode msgCode) {
        this.code = msgCode.getCode();
        this.message = msgCode.getMessage();
        this.data = "";
    }

    public ResultModel(MessageCode msgCode, Object data) {
        this.code = msgCode.getCode();
        this.message = msgCode.getMessage();
        this.data = data;
    }

    public static ResultModel ok() {
        return new ResultModel(MessageCode.OK);
    }

    public static ResultModel ok(Object content) {
        return new ResultModel(MessageCode.OK, content);
    }

    public static ResultModel error(ResultModel error) {
        return new ResultModel(error);
    }
}